package com.youfang.sixthmedia;

import java.util.List;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;

import com.gzit.common.async.AsynCallback;
import com.gzit.utils.AndroidUtils;
import com.youfang.sixthmedia.message.GethousesRequest;
import com.youfang.sixthmedia.message.GethousesResponse;
import com.youfang.sixthmedia.message.model.Building;
import com.youfang.sixthmedia.net.Net;
import com.youfang.sixthmedia.net.Response;

public class YoufangActivity extends Activity {
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		// NewClassRequest req = new NewClassRequest();
		// req.setCityid(""+35);
		//
		// NetInterface.doHttpRemote(this, req, new NewClassResponse(), new
		// AsynCallback<Response>() {
		//
		//
		//
		// @Override
		// public void callback(Response r) {
		//
		//
		//
		// }
		// });

		this.findViewById(R.id.gethouses).setOnClickListener(
				new OnClickListener() {

					@Override
					public void onClick(View v) {

						gethouses();

					}
				});

	}

	private void gethouses() { 

		GethousesRequest req = new GethousesRequest();
		// req.setAreaid("aa");
		req.setCityid(35);
		// req.setKeyword("");
		Net.doHttpRemote(this, req, new GethousesResponse(),
				new AsynCallback<Response>() {

					@Override
					public void callback(Response r) {
						if (!r.isOk()) {
							return;
						}
						
						GethousesResponse resp = (GethousesResponse)r;
						List<Building> buildings = resp.getBuildings();
						AndroidUtils.toastLong(""+buildings.size());
						

					}
				});
	}

}